package com.pluginsacceptor.plugin.formula.statistics;

import javax.swing.JMenu;
import javax.swing.JMenuItem;

import com.pluginsacceptor.plugin.formula.MathsTrigo.support.DataListener;
import com.pluginsacceptor.plugin.formula.MathsTrigo.support.DataSender;

public class StatisticsMenu extends JMenu{



	 private final DataListener dataListener;
	private final DataSender dataSender;

    private static final long serialVersionUID = -3110316243457377854L;

	public StatisticsMenu(final DataListener dataListener, final DataSender dataSender)  {

		super("Statistiques");
		this.dataListener = dataListener;
	    this.dataSender = dataSender;
		addItems();
		addListeners();


	 		}


	 	JMenuItem moyenne;
	 	JMenuItem moyHarmo;
	 	JMenuItem min;
	 	JMenuItem max;
	 	JMenuItem mediane;
	 	JMenuItem variance;
	 	JMenuItem ecartType;
	 	JMenuItem nb;
	 	JMenuItem pourcentage;


	private void addItems() {

		moyenne = new JMenuItem("Moyenne");
		add(moyenne);

		max = new JMenuItem("Max");
		add(max);

		min = new JMenuItem("Min");
		add(min);

		moyHarmo = new JMenuItem("Moyenne harmonique");
		add(moyHarmo);

		ecartType = new JMenuItem("Ecart type");
		add(ecartType);

		mediane = new JMenuItem("Mediane");
		add(mediane);

		pourcentage = new JMenuItem("Pourcentage");
		add(pourcentage);

		nb = new JMenuItem("Nb");
		add(nb);

		variance = new JMenuItem("variance");
		add(variance);
	}

	private void addListeners() {

		moyenne.addActionListener(new MoyenneListenerCalcul(dataListener, dataSender));
		moyHarmo.addActionListener(new MoyenneHarmoListenerCalcul(dataListener, dataSender));
		max.addActionListener(new MaxListenerCalcul(dataListener, dataSender));
		min.addActionListener(new MinListenerCalcul(dataListener, dataSender));
		mediane.addActionListener(new MedianeListenerCalcul(dataListener, dataSender));
		variance.addActionListener(new VarianceListenerCalcul(dataListener, dataSender));
		nb.addActionListener(new NbListenerCalcul(dataListener, dataSender));
		pourcentage.addActionListener(new PourcentageListenerCalcul(dataListener, dataSender));
		ecartType.addActionListener(new EcartTypeListenerCalcul(dataListener, dataSender));
	}
}
